package com.qf.controller;

import com.qf.entity.Student;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Date;

@Controller
@RequestMapping("/mapper")
public class TsetController {
    @RequestMapping("/basic")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    public void basicCollect(String username, String password, String gender, Integer age, Double salary, Date birthday) {
        System.out.println("username = " + username + ", password = " + password + ", gender = " + gender + ", age = " + age + ", salary = " + salary + ", birthday = " + birthday);
    }

    @RequestMapping("/collect")
    public void collectObject(Student student) {
        System.out.println(student);
    }
    @RequestMapping("/basic1")
    public void basicCollect2(@RequestParam(value = "username",defaultValue = "0") String username, String password, String gender, Integer age, Double salary, Date birthday){
        System.out.println("username = " + username + ", password = " + password + ", gender = " + gender + ", age = " + age + ", salary = " + salary + ", birthday = " + birthday);
    }
    @RequestMapping("/array")
    public void collectArray(String[] hobby){
        for (String s : hobby) {
            System.out.println(s);
        }
    }
    @RequestMapping("/path/{id}")
    public void pathVar(@PathVariable(value = "id") Integer id){
        System.out.println(id);
    }
}
